/*
 * @Author: szx
 * @Date: 2021-10-21 13:22:53
 * @LastEditTime: 2021-10-21 13:32:48
 * @Description:
 * @FilePath: \leetcode\66\66.go
 */

package main

import "fmt"

func plusOne(digits []int) []int {
	flag := true
	for i := len(digits) - 1; i >= 0; i-- {
		if !flag {
			return digits
		}
		digits[i]++
		if digits[i]/10 == 1 {
			digits[i] %= 10
		} else {
			flag = false
		}
	}
	if flag {
		return append([]int{1}, digits...)
	}
	return digits
}

func main() {
	var arr []int = []int{0}
	fmt.Printf("%v", plusOne(arr))
}
